home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 17
/
CU Amiga Magazine's Super CD-ROM 17 (1997)(EMAP Images)(GB)[!][issue 1997-12].iso
/
CUCD
/
Programming
/
DiceSource
/
lib
/
memory
/
cmpmem.a
< prev
next >
Wrap
Text File
|
1994-02-01
|
1KB
|
80 lines
; CMPMEM.A
;
; (c)Copyright 1990, Matthew Dillon, All Rights Reserved
section text,code
; CMPMEM (s1, s2, len)
; MEMCMP (s1, s2, len) ANSI
; BCMP (s1, s2, len) UNIX
; A0 A1 D0 internal args
; 4(sp) 8(sp) 12(sp)
xdef _cmpmem
xdef _bcmp
xdef _memcmp
xdef @cmpmem
xdef @bcmp
xdef @memcmp
xdef _hyper_cmpmem
xdef _hyper_bcmp
xdef _hyper_memcmp
_hyper_memcmp:
_hyper_cmpmem:
_hyper_bcmp:
_memcmp:
_cmpmem:
_bcmp:
move.l 4(sp),A0
move.l 8(sp),A1
move.l 12(sp),D0
@memcmp:
@cmpmem:
@bcmp:
move.l D0,D1
move.w A0,D0 ; not word aligned adress.
lsr.l #1,D0
bcs xcmbyte
move.w A1,D0
lsr.l #1,D0
bcs xcmbyte
move.l D1,D0 ; save D1
lsr.l #2,D1 ; # of longwords to compare
xcmlong subq.l #1,D1
bcs xcmlbreak
xcmlloop cmpm.l (A0)+,(A1)+
dbne D1,xcmlloop
bcs xcmendp
bhi xcmendn
sub.l #$10000,D1
bcc xcmlloop
xcmlbreak
move.l D0,D1 ; get original bytes
and.l #3,D1 ; # bytes left to compare
xcmbyte subq.l #1,D1
bcs xcmbbreak
xcmbloop cmpm.b (A0)+,(A1)+
dbne D1,xcmbloop
bcs xcmendp
bhi xcmendn
sub.l #$10000,D1
bcc xcmbloop
xcmbbreak
xcmend0 moveq.l #0,D0
rts
xcmendp moveq.l #1,D0
rts
xcmendn moveq.l #-1,D0
rts
END